package com.woniu108.valueAdded;

import cn.hutool.json.JSONUtil;
import com.woniu108.valueAdded.model.Ticket;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

public class test {

    public static void main(String[] args) {
    //测试jsonstr转list格式
        List<Ticket> list=new ArrayList<>();
        Ticket ticket1 = new Ticket();
        Ticket ticket2 = new Ticket();
        ticket1.setTicketId(1);
        ticket2.setTicketId(2);
        ticket1.setTicketType("普通优惠券");
        ticket2.setTicketType("会员优惠券");
        ticket1.setCutDownPrice(BigDecimal.valueOf(200));
        ticket2.setCutDownPrice(BigDecimal.valueOf(300));
        ticket1.setAllowUsePrice(BigDecimal.valueOf(500));
        ticket2.setAllowUsePrice(BigDecimal.valueOf(600));
        ticket1.setLimitTime(60);
        ticket2.setLimitTime(30);
        ticket1.setAllowVipLevel(0);
        ticket2.setAllowVipLevel(1);
        list.add(ticket1);
        list.add(ticket2);


        String jsonStr = JSONUtil.toJsonStr(list);
        System.out.println(jsonStr);
        System.out.println("===========================================");
        List<Ticket> Tickets = JSONUtil.toList(jsonStr, Ticket.class);
        for (Ticket ticket : Tickets) {
            System.out.println(ticket);
        }
        //测试时间判断
        boolean b = LocalDateTime.now().plusDays(2L).isAfter(LocalDateTime.now());
        System.out.println(b);
    }
}
